package org.springblade.modules.mes.opcua.constant;

import org.springblade.modules.mes.quality.vo.MaterialCountVO;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class CountMapUtil {

	public static Map<String, Long> toMap(List<MaterialCountVO> dataList) {
		Map<String, Long> cMap = new HashMap<>();
		for (MaterialCountVO t : dataList) {
			if (t.getCountNum() == null) {
				cMap.put(t.getMatNo(), 0L);
			} else {
				cMap.put(t.getMatNo(), t.getCountNum());
			}

		}
		return cMap;
	}

	public static Long getValue(Map<String, Long> matMap, String mat) {
		Long useCount = matMap.get(mat);
		if (useCount == null) {
			useCount = 0L;
		}
		return useCount;
	}


}
